package com.fwtai.controller.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.service.web.ConversionService;
import com.fwtai.tool.ToolClient;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 积分兑换记录控制层|路由层
 * @作者 田应平
 * @版本 v1.0
 * @QQ号码 444141300
 * @创建日期 2023-04-19 10:20:18
 * @官网 <url>http://www.fwtai.com</url>
*/
@RestController
@RequestMapping("/conversion")
public class ConversionController{

  private final ConversionService conversionService;

  public ConversionController(final ConversionService conversionService){
    this.conversionService = conversionService;
  }

  /**兑换(行内)*/
  @PreAuthorize("hasAuthority('securities_btn_audit')")
  @PostMapping("/editBatchAudit")
  public void editBatchAudit(final String kid,final Integer audit_status,final String total,final String comment,final String user_id,final HttpServletResponse response){
    ToolClient.responseJson(conversionService.editBatchAudit(kid,audit_status,total,comment,user_id),response);
  }

  /**获取数据*/
  @PreAuthorize("hasAuthority('securities_btn_listData')")
  @GetMapping("/listData")
  public void listData(final HttpServletRequest request,final HttpServletResponse response){
    ToolClient.responseJson(conversionService.listData(new PageFormData(request)),response);
  }
}